<template>
	<view style="overflow: hidden;" class="">		
		<view :class="isopen?'bgc2':'bgc'">
			<view class="bgc" v-if="!isopen">
				<image style="width: 100%;height: 100%;" src="../static/images/redPackets_ing1.jpg" mode=""></image>
			</view>
			<view class="bgc2" v-if="isopen">
				<image style="width: 100%;height: 100%;" src="../static/images/redPackets_ing2.jpg" mode=""></image>
			</view>
			 <text style="font-size: 50rpx;color: #FFFFFF;font-weight: bold;">{{isopen}}</text>  
			<view @click="open()" v-if="!isopen" class="btn">
			</view>
			<view @click="toDetail" v-if="isopen" class="btn2">
				<!-- 查看详情 -->
			</view>
		<!-- 	<view v-if="lis.is_receive" class="mask">
				
			</view> -->
			<view v-if="isopen" >
				<view class="contentBox" v-if="isfinish">
					<view style="font-size: 100upx;padding-left: 34upx;color: #70342c;" >来晚了</view>
					<view style="font-size: 60upx;padding-left: 34upx;color: #ffc743;margin-top: 80rpx;" >红包派完了</view>
					<!-- <view style="font-size: 36upx;padding-left: 34upx;" class="Cfedc32">
						恭喜抢到
					</view>
					<view style="font-size: 36upx;padding-left: 34upx;margin-top: -10upx;line-height: 100upx;" class="Cfedc32">
						<text>￥</text> <text style="font-size: 50upx;padding: 0 5upx;">{{get_amount}}</text> <text style="position: relative;top: -8upx;">红包</text>
					</view> -->
				</view>
				
				<view class="contentBox" v-if="!isfinish">
					<view style="font-size: 100upx;padding-left: 34upx;color: #70342c;" >￥{{get_amount}}</view>
					<view style="padding-left: 34upx;color:red;margin-top: -30rpx;">已存入积分</view>
					<view style="font-size: 60upx;padding-left: 34upx;color: #ffc743;margin-top: 80rpx;" >小主，恭喜你！</view>
					<!-- <view style="font-size: 36upx;padding-left: 34upx;" class="Cfedc32">手慢了</view>
					<view style="font-size: 36upx;padding-left: 34upx;margin-top: -10upx;line-height: 100upx;" class="Cfedc32">红包已经抢完了</view> -->
				</view>
			</view>
		</view>
	</view>	
</template>

<script>
		// #ifdef H5
			const share = require("@/store/share.js")
		// #endif
	export default {
		data(){
			return{
				lis:{},
				lis2:{},
				isOpenFlag:false,
				list:[],
				curpage:1,
				hasmore:0,
				get_amount:0,
				activity_id:15,
				backgroundimage:"../static/images/redPackets_ing1.jpg",
				isopen:false,
				isDisable:false,//禁用领取按钮
				isfinish:false
			}
		},
		onLoad(options) {
			this.activity_id=options.activity_id || 1;
			this.getLis()
			// #ifdef H5
			
			// #endif
		},
		onShow() {
			// this.getLis()
		},
		methods:{	
			toDetail(){
				uni.redirectTo({
					url:'getLists?activity_id='+this.lis.id
				})
			},
			open(){	
				if(this.isDisable){
					return false
				}
				uni.showLoading({})
				this.isDisable=true;
				var that=this
				this.$util.request({
					url: '/mobile/index.php?act=wxrp_activity&op=open',
					method: 'get',
					data: {
						"activity_id":this.activity_id
					},
				}).then((res)=> {
					uni.hideLoading()					
					if(res.error_code == 0){
						this.isDisable=false;
						that.get_amount=res.datas.amount
						that.backgroundimage="../static/images/redPackets_ing2.jpg"
						that.isopen=true
						// that.getLis()						
					}else if(res.error_code == 130009){
						that.isopen=true
						that.isfinish=true
						uni.redirectTo({
							url:'getLists?activity_id='+this.lis.id
						})
					} else{
						this.isDisable=false;
						uni.showToast({
							title:res.message,
							icon:"none"
						})
					}
				})
			},
			getLis(){
				this.$util.request({
					url: '/mobile/index.php?act=wxrp_activity&op=index',
					method: 'get',
					data: {
						"activity_id":this.activity_id
					},
				}).then((res)=> {
					if(res.error_code == 0){
						this.lis=res.datas.activity
						// #ifdef H5
							let shareInfo={
								title: this.lis.wishing , // 分享标题
								desc: this.lis.share_desc, // 分享描述  
								link:  this.$share+"/#/operation/redPackets/redPacketsDetail?activity_id="+this.activity_id, // 分享链接  
								imgUrl: this.lis.share_img, // 分享图标       
								}
							share.share(shareInfo)
								
						// #endif
						if(this.lis.is_receive == 1){
							this.backgroundimage="../static/images/redPackets_ing2.jpg"
							this.isopen=true;
							this.get_amount=res.datas.activity.ged_amount
							// setTimeout(()=>{
								// uni.redirectTo({
								// 	url:'getLists?activity_id='+this.lis.id
								// })
							// },1000)
						}
					}else{
						uni.showToast({
							title:res.message,
							icon:"none"
						})
						// setTimeout(()=>{
						// 	uni.navigateBack({
						// 		delta:1
						// 	})
						// },1000)
					}
				})
			}
	
			
			
		}
	}
</script>

<style>
	view{		
		box-sizing: border-box;
	}
	.titleNview-placing {
		height: var(--status-bar-height);
		box-sizing: content-box;
	 }
	.lh20{
		line-height: 20upx;
		height: 20upx;
	}
	.lh25{
		line-height: 25upx;
	}
	.lh30{
		line-height: 30upx;
	}
	.lh35{
		line-height: 35upx;
	}
	.lh40{
		line-height: 40upx;
	}
	.lh45{
		line-height: 45upx;
	}
	.lh50{
		line-height: 50upx;
	}
	.lh80{
		line-height: 80upx;
	}
	.C000{
		color: #000000;
	}
	.Ce13d97{
		color: #ff4300;
	}
	.Cfe0000{
		color: #ff4300;
	}
	.Cc06{
		color: #ff4300;
	}
	.mt55mb30{
		margin-top: 55upx;
		margin-bottom: 30upx;
	}
	.Cfff{
		color: #FFFFFF;
	}
	
	.flex{		
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-content: space-between;
	}
	.paddingL20{
		padding-left: 20upx;
	}
	.C999{
		color:#999 ;
	}
	.Cff0101{
		color:#ff0101 ;
	}
	.Cc00251{
		color: #c00251;
	}
	.strick{
		text-decoration: line-through;
	}
	.Cfe0000{
		color: #ff4300;
	}
	.line1{
		width: 430upx;
	}
	.hide{
		display: none;
	}
	.marginB20{
		margin-bottom: 20upx;
	}
	
	.twoline{
	   overflow : hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
	.pl20{
		padding-left: 20upx;
	}
	.positionT{
		position: relative;
		top: 50upx;
	}
	.paddingB15{
		padding-bottom: 15upx;
	}
	.borderB{
		border-bottom: 1px solid #f4f4f6;
	}
	.borderT{
		border-top: 1px solid #f4f4f6;
	}
	.gl{
		position: absolute;
		right: 30upx;
	}
	.pr30{
		padding-right: 30upx;
	}
	.C333{
		color: #333333;
	}
	.C666{
		color: #666666;
	}
	.Cf00{
		color: #ff0000;
	}
	
	.bold{
		font-weight: bold;
	}
	.C1d1d1d{
		color:#1d1d1d ;
	}
	.fl{
		float: left;
	}
	.fr{
		float: right;
	}
	.tac{
		text-align: center;
	}
	.Ce5258e{
		color: #e5258e;
	}
	.Cccc{
		color: #CCCCCC;
	}
	.Cfedc32{
		color: #fedc32;
		text-align: center;
		width: 100%;
	}
	uni-page-body {
		background-color: #f5f5f5;
		color: rgb(102, 102, 102);
	}		
	.fs30{
		/* font-size: 30upx */
		font-size: 45upx
	}
	.fs26{
		font-size:39upx
		/* font-size: 26upx */
	}
	.fs12{
		font-size: 18upx
		/* font-size: 12upx */
	}
	.fs16{
		font-size: 24upx
		/* font-size: 16upx */
	}
	.fs14{
		font-size: 21upx
		/* font-size: 14upx */
	}
	.fs15{
		font-size: 22.5upx
		/* font-size: 15upx */
	}
	.fs27{
		font-size: 40.5upx
		/* font-size: 27upx */
	}
	.fs18{
		font-size: 27upx
		/* font-size: 18upx */
	}
	.fs28{
		font-size: 42upx
		/* font-size: 28upx */
	}
	.fs10{
		font-size: 15upx
		/* font-size: 10upx */
	}
	.fs30{
		font-size: 45upx
		/* font-size: 28upx */
	}
	.fs24{
		font-size: 36upx
		/* font-size: 24upx */
	}
	.fs20{
		font-size:30upx
		/* font-size: 20upx */
	}
	.fs22{
		font-size:33upx
		/* font-size: 22upx */
	}
	.fs21{
		font-size: 31.5upx
		/* font-size: 21upx */
	}	
	.flexsb{
		display: flex;
		justify-content: space-between;
	}
	.plr20{
		padding: 0 20upx;
	}
	.plr10{
		padding: 0 10upx;
	}
	.oneline{
	   overflow : hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.bgc{
		position: fixed;
		top: 0;
		width: 100%;
		height: 100vh;
		/* margin-top: -105upx; */
		background-color: #632011;
		background-image: url(../static/images/redPackets_ing1.jpg);
		background-size: 100% 100%;
		overflow: hidden;
		background-repeat: no-repeat;
	}
	.bgc2{
		width: 100%;
		height: 93vh;
		/* margin-top: -105upx; */
		background-color: #632011;
		background-image: url(../static/images/redPackets_ing2.jpg);
		background-size: 100% 100%;
		overflow: hidden;
		background-repeat: no-repeat;
	}
	
	.btn{
		width: 500upx;
		height: 270upx;
		line-height: 70upx;
		font-size: 45upx;
		color: #f4ce5b;
		text-align: center;
		position: fixed;
		left: 20%;
		/* margin-left: -15%; */
		top: 55%;
		z-index: 39;
		
	}
	.btn2{
		width:60%;
		height: 200upx;
		line-height: 70upx;
		font-size: 45upx;
		color: #333;
		/* background-color: #fedc32; */
		text-align: center;
		position: fixed;
		left: 40%;
		margin-left: -20%;
		top: 55%;
		z-index: 39;
		border-radius: 20rpx;
	}
	.contentBox{
		width: 500rpx;
		height: 180upx;
		text-align: center;
		margin-top: 250upx;
		position: relative;
		position: fixed;
		top:6%;
		margin-left: -200rpx;
		left: 40%;
		/* background-color: #FFFFFF;
		z-index: 99999999999; */
	}
	.mask{
		width: 560upx;
		height: 750upx;
		background-color: rgba(0,0,0,0.3);
		position: absolute;
		left: 50%;
		transform: translateX(-46.5%);
		margin-top: 155upx;
		z-index: 9;
		/* border: 1upx dashed #3699ff; */
	}
</style>
